#ifndef QUICKTIMER_H
#define QUICKTIMER_H

#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QList>
#include <QSound>
#include <QSettings>

#include <iostream>

#include "ui_createAlarm.h"
#include "alarm.h"

class QuickTimer : public QDialog, public Ui_createAlarmDialog
{
    Q_OBJECT

public:
    QuickTimer(QDialog *parent = 0);
    ~QuickTimer();

protected:
    void timerEvent(QTimerEvent *event);

private slots:
    void iconActivated(QSystemTrayIcon::ActivationReason reason);
    void messageClicked();

    void showCreateAlarm();

    void createNewAlarm();
    void cancelNewAlarm();
    void setAlarmTimeLabel();

    void removeMenuAction(QAction *action);
    void alarmMessagePreviousComboBoxClicked(QString message);

private:
    QSettings *settings;

    QSystemTrayIcon *trayIcon;
    QMenu *trayIconMenu;
    QSystemTrayIcon::MessageIcon trayMessageIcon;

    QAction *quitAction;
    QAction *newAlarmAction;
    QSound *sound;

    QList<Alarm *> alarmList;
    QList<Alarm *> alarmEventList;
    QStringList alarmMessageList;

    QBasicTimer clockRefreshTimer;
    QBasicTimer trayAnimationTimer;
    QIcon trayIcons[12];
    int trayAnimationIconIndex;

    bool alarmMessageActive;
    Alarm *currentAlarmEvent;

    QAction *lastSeperator;

    void closeNewAlarm();
    void createActions();
    void createTrayIcon();
    void createConnections();
    void setTrayIcon();
    void processNextAlarmEvent();
    void showCurrentAlarmEvent();
    QTime calcAlarmTime();
    void updateToolTip();

    void writeSettings();
    void readSettings();

};

#endif // QUICKTIMER_H
